package com.base.collection.map;

import java.util.*;

/**
 * Map的存取和遍历
 *
 * @author innocent
 * @date 2019/1/8 15:27
 */
public class SimpleMap {

    public static void main(String[] args) {
        Map<String,Object> map = new HashMap();
        map.put("name","悟空");
        map.put("age","900");
        map.put("address","地球");

        Collection values = map.values();
        for (Object value : values) {
            System.out.println("value = " + value);
        }

        Set set = map.keySet();
        for (Object o : set) {
            System.out.println(map.get(o) +" = " + o);
        }

        System.out.println("-----------> Map推荐遍历方式");
        for (Map.Entry<String,Object> entry : map.entrySet()) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
    }
}
